export const formatTree = (list, rootPid) => {
  // 空数组
  const arr = []
  list.map(item => {
    // 顶级找下属
    if (item.pid === rootPid) {
      const children = formatTree(list, item.id)
      // 找到了
      if (children.length) item.children = children
      arr.push(item)
    }
  })
  // 返回值
  return arr
}
